﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Class_Entity;
using DataAccess;
using System.Data;
using System.Net;
using System.Net.Mail;

namespace BussinessObject
{
    public class BOQuoteUs
    {
        public bool Add_QuoteUs(QuoteUs qu)
        {
            DAQuoteUs dqu = new DAQuoteUs();
            return dqu.Add_QuoteUs(qu);
        }


        //----------------------------------------------------------------------------------

        public bool Delete_QuoteUs(QuoteUs qu)
        {
            DAQuoteUs dqu = new DAQuoteUs();
            return dqu.Delete_QuoteUs(qu);
        }


        //----------------------------------------------------------------------------------

        public DataSet Load_QuoteUs(QuoteUs qu)
        {
            DAQuoteUs dqu = new DAQuoteUs();
            return dqu.Load_QuoteUs(qu);
        }

        //----------------------------------------------------------------------------------

        public DataSet Search_QuoteUs(QuoteUs qu)
        {
            DAQuoteUs dqu = new DAQuoteUs();
            return dqu.Search_QuoteUs(qu);
        }


        //----------------------------------------------------------------------------------

        public void Reply_QuoteUs(string toEmail, string subject, string content)
        {

            try
            {
                //Step 1
                MailAddress fromAddress = new MailAddress("nguyenthgc60201@fpt.edu.vn");
                MailAddress toAddress = new MailAddress(toEmail);
                //Step 2
                MailMessage mailclient = new MailMessage(fromAddress, toAddress);
                mailclient.Subject = subject;
                mailclient.Body = content;

                //Step 3
                //Attachment attachfile = new Attachment("");
                //mailclient.Attachments.Add(attachfile);
                //Step 4
                SmtpClient smtpMail = new SmtpClient("smtp.gmail.com", 587);
                //Step 5
                smtpMail.Credentials = new NetworkCredential("eprojectonlinepharmacy@gmail.com", "a123456z");
                smtpMail.EnableSsl = true;
                smtpMail.DeliveryMethod = SmtpDeliveryMethod.Network;
                //Step 6
                smtpMail.Send(mailclient);
                
            }
            catch (Exception ex)
            {
                
            }
        }
    }
}
